namespace MasoQna.Migrations
{
    using System.Data.Entity.Migrations;
    
    public partial class InitialCreate : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "Writings",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        UpVoteCount = c.Short(nullable: false),
                        DownVoteCount = c.Short(nullable: false),
                        Content = c.String(),
                        Time = c.DateTime(nullable: false),
                        QuestionId = c.Int(),
                        Title = c.String(),
                        ViewCount = c.Int(),
                        SelectedAnswerId = c.Int(),
                        Discriminator = c.String(nullable: false, maxLength: 128),
                        Writer_Id = c.Int(),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("Users", t => t.Writer_Id)
                .ForeignKey("Writings", t => t.QuestionId)
                .Index(t => t.Writer_Id)
                .Index(t => t.QuestionId);
            
            CreateTable(
                "Users",
                c => new
                    {
                        Id = c.Int(nullable: false, identity: true),
                        Name = c.String(maxLength: 20),
                        Reputation = c.Long(nullable: false),
                    })
                .PrimaryKey(t => t.Id);
            
        }
        
        public override void Down()
        {
            DropIndex("Writings", new[] { "QuestionId" });
            DropIndex("Writings", new[] { "Writer_Id" });
            DropForeignKey("Writings", "QuestionId", "Writings");
            DropForeignKey("Writings", "Writer_Id", "Users");
            DropTable("Users");
            DropTable("Writings");
        }
    }
}
